package cn.wolfcode.util;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/**
 * @author 李新雨的项目86176
 * @version 1.0
 * @date 2024-10-07 18:02
 */
public abstract class MyBaitUtils {
    private static SqlSessionFactory ssf;


    static {

        InputStream is=null;
        try {
            is = Resources.getResourceAsStream("mybatis-config.xml");
            ssf=new SqlSessionFactoryBuilder().build(is);

        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (is!=null)
                try {
                    is.close();
                }
                 catch (IOException e) {
                     e.printStackTrace();
                 }
        }

    }
    public static SqlSession getSSF() {
        return ssf.openSession();
    }
}
